import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:tender_flutter/constant/theme_colors.dart';
import 'package:tender_flutter/page/home/model/article_entity.dart';
import 'package:tender_flutter/utils/screen_adaper.dart';
import 'package:tender_flutter/widgets/net_image.dart';

class ArticleListCell extends StatelessWidget {
  const ArticleListCell({Key key, this.data, this.onTap}) : super(key: key);

  final ArticleList data;
  final GestureTapCallback onTap;

  @override
  Widget build(BuildContext context) {
    return _initCell();
  }

  Widget _initCell() {
    return GestureDetector(
        onTap: onTap,
        child: Container(
          margin: EdgeInsets.only(
              left: ScreenAdapter.width(30), right: ScreenAdapter.width(30)),
          width: double.infinity,
          decoration: BoxDecoration(
              color: ThemeColors.colorWhite,
              borderRadius: BorderRadius.circular(ScreenAdapter.width(14))),
          child: Row(
            children: <Widget>[
              Container(
                width: ScreenAdapter.width(200),
                height: ScreenAdapter.width(155),
                margin: EdgeInsets.only(right: ScreenAdapter.width(18)),
                child: MyNetImage(
                    url: data.pic ?? "",
                    radius: BorderRadius.circular(ScreenAdapter.width(14))),
              ),
              Expanded(
                  child: Column(
                mainAxisAlignment: MainAxisAlignment.end,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    data.title,
                    maxLines: 2,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                        color: ThemeColors.colorType24,
                        fontSize: ScreenAdapter.sp(32),
                        fontWeight: FontWeight.w500),
                  ),
                  SizedBox(height: ScreenAdapter.height(50)),
                  // Expanded(child: SizedBox()),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text("${data.views}人看过",
                          style: TextStyle(
                              color: ThemeColors.colorType46,
                              fontSize: ScreenAdapter.sp(26))),
                      Text(data.createDate,
                          style: TextStyle(
                              color: ThemeColors.colorType46,
                              fontSize: ScreenAdapter.sp(26)))
                    ],
                  )
                ],
              ))
            ],
          ),
        )
//      Stack(
//        children: <Widget>[
//          ,
//          Container(
//            alignment: Alignment.topRight,
//            child: Image.asset(RPath.imgPath + "icon_top.png"))
//        ],
//      ),
        );
  }
}
